-- titan_shield
-- created by zhuangsl
-- 泰坦护盾，每次受创后，所受伤害减少x%（可叠加，有上限）

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 受创触发
    trigger = function(who, prop, arg)
        -- 当前值和上限
        local p = PropM.combine(who, "damage", "titan");
        local limit = tonumber(prop[2]);

        if p[3] == limit then
            return;
        end

        -- 减伤率，不能超过上限
        local rate = math.min(p[3] + prop[3], limit);

        -- 持续本层
        local condition = {
            ["value"] = rate,
            ["end_round"] = -1,
        }

        -- 附加状态
        CombatStatusM.applyStatus(who, "titan_shield", condition);

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });
    end,

    record = function(target, prop, path)
        return false;
    end
};